﻿--
-- Dropping stored procedure pr_HangHoa_SelectAll : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_HangHoa_SelectAll]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_HangHoa_SelectAll]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_HangHoa_SelectAll
-- Author:	MinhNN
-- Create date:	5/14/2012 9:58:36 PM
-- Description:	This stored procedure is intended for selecting all rows from HangHoa table
-- ==========================================================================================
Create Procedure pr_HangHoa_SelectAll
As
Begin
	Select 
		[MaHH],
		[TenHH],
		[MaLH],
		[DonViTinh],
		[DonGia],
		[ThongTinNSX]
	From HangHoa
End

GO


--
-- Dropping stored procedure pr_HangHoa_SelectRow : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_HangHoa_SelectRow]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_HangHoa_SelectRow]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_HangHoa_SelectRow
-- Author:	MinhNN
-- Create date:	5/14/2012 9:58:36 PM
-- Description:	This stored procedure is intended for selecting a specific row from HangHoa table
-- ==========================================================================================
Create Procedure pr_HangHoa_SelectRow
	@MaHH varchar(10)
As
Begin
	Select 
		[MaHH],
		[TenHH],
		[MaLH],
		[DonViTinh],
		[DonGia],
		[ThongTinNSX]
	From HangHoa
	Where
		[MaHH] = @MaHH
End

GO


--
-- Dropping stored procedure pr_HangHoa_Insert : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_HangHoa_Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_HangHoa_Insert]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_HangHoa_Insert
-- Author:	MinhNN
-- Create date:	5/14/2012 9:58:36 PM
-- Description:	This stored procedure is intended for inserting values to HangHoa table
-- ==========================================================================================
Create Procedure pr_HangHoa_Insert
	@MaHH varchar(10),
	@TenHH nvarchar(50),
	@MaLH varchar(10),
	@DonViTinh nvarchar(50),
	@DonGia decimal,
	@ThongTinNSX nvarchar(200)
As
Begin
	Insert Into HangHoa
		([MaHH],[TenHH],[MaLH],[DonViTinh],[DonGia],[ThongTinNSX])
	Values
		(@MaHH,@TenHH,@MaLH,@DonViTinh,@DonGia,@ThongTinNSX)

End

GO


--
-- Dropping stored procedure pr_HangHoa_Update : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_HangHoa_Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_HangHoa_Update]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_HangHoa_Update
-- Author:	MinhNN
-- Create date:	5/14/2012 9:58:36 PM
-- Description:	This stored procedure is intended for updating HangHoa table
-- ==========================================================================================
Create Procedure pr_HangHoa_Update
	@MaHH varchar(10),
	@TenHH nvarchar(50),
	@MaLH varchar(10),
	@DonViTinh nvarchar(50),
	@DonGia decimal,
	@ThongTinNSX nvarchar(200)
As
Begin
	Update HangHoa
	Set
		[TenHH] = @TenHH,
		[MaLH] = @MaLH,
		[DonViTinh] = @DonViTinh,
		[DonGia] = @DonGia,
		[ThongTinNSX] = @ThongTinNSX
	Where		
		[MaHH] = @MaHH

End

GO


--
-- Dropping stored procedure pr_HangHoa_DeleteRow : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_HangHoa_DeleteRow]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_HangHoa_DeleteRow]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_HangHoa_DeleteRow
-- Author:	MinhNN
-- Create date:	5/14/2012 9:58:36 PM
-- Description:	This stored procedure is intended for deleting a specific row from HangHoa table
-- ==========================================================================================
Create Procedure pr_HangHoa_DeleteRow
	@MaHH varchar(10)
As
Begin
	Delete HangHoa
	Where
		[MaHH] = @MaHH

End

GO
